var tablename = "news";
var newsid;
module.exports = {
	get: function(req, res) {
		newsid = req.query.newsid;
		// console.log("查询表“", tablename, "”的数据", req.body, req.query);
		var finner = req.models[tablename].find({
			"newsid": req.query.newsid,
		});
		require("../../include/RESTful_query").orm_get(finner, req.query);

		finner.run(function(err, result) {
			if (err) {
				res.send(500, err);
			} else {
				res.send(result);
			}
		});
	},
	put: function(req, res) {
		// console.log("为表“", tablename, "”进行修改：", req.body, req.query);
		req.models[tablename].get(newsid, function(err, result) {
			if (err) {
				res.send(500, err);
			} else {
				for (newsid in result) {
					result['newstitle'] = req.body.newstitle;
					result['author'] = req.body.author;
					result['newstext'] = req.body.newstext;
				};
				result.save(function(err) {
					if (err) {
						res.send(500, err);
					} else {
						res.send(true);
					}
				});
			}
		});
	}
}